#include "Header.h"
//#include "def_pointer.h"
//"def_pointer.h" should only be included once, since there shouldn't be more than one definition of a variable. (It is a different case for dynamic library, which needs definition of global variables rather than "extern" declaration, in that case "def_pointer.h" should appear in both main.c and func.c)

int main(void) {
    char dir[1000];
    double T1, T2;
    scanf("read %s %lf %lf", dir, &T1, &T2);
    fp = fopen(dir, "r");
    if (fp == NULL)
        printf("Error! No such file.");
    struct RiffChunk riff;
    readChunk(&riff);
    if (riff.chunkID[0] != 'R' || riff.chunkID[1] != 'I' || riff.chunkID[2] != 'F' || riff.chunkID[3] != 'F')
        printf("%s\n", "Error! Not a .wav file.");
    else{
        printChunk(&riff);
        moveForward("fmt ");
        
        struct FmtChunk fmt;
        readSubchunk1(&fmt);
        printSubchunk1(&fmt);
        moveForward("data");
        
        struct DataChunk data;
        readSubchunk2(&data);
        printSubchunk2(&data, fmt.numChannels, fmt.byteRate, fmt.bitsPerSample, fmt.sampleRate, T1, T2);
    }
}
